/*
-----------------------------------------------------------------------------
This source file is part of OGRE
    (Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/

Copyright (c) 2000-2005 The OGRE Team
Also see acknowledgements in Readme.html

This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA, or go to
http://www.gnu.org/copyleft/lesser.txt.
-----------------------------------------------------------------------------
*/
#include "vector3.h"
#include "sgeMath.h"
#include <boost/python.hpp>

namespace sge
{
    const Vector3 Vector3::ZERO( 0, 0, 0 );

    const Vector3 Vector3::UNIT_X( 1, 0, 0 );
    const Vector3 Vector3::UNIT_Y( 0, 1, 0 );
    const Vector3 Vector3::UNIT_Z( 0, 0, 1 );
    const Vector3 Vector3::NEGATIVE_UNIT_X( -1,  0,  0 );
    const Vector3 Vector3::NEGATIVE_UNIT_Y(  0, -1,  0 );
    const Vector3 Vector3::NEGATIVE_UNIT_Z(  0,  0, -1 );
    const Vector3 Vector3::UNIT_SCALE(1, 1, 1);
    
        
    boost::python::object Vector3::getPyTuple() {
        return boost::python::make_tuple(x,y,z);
        //return boost::python::object(toString());
    }
    
    std::string Vector3::toString() {
        std::ostringstream ss;
        ss << "(" << x << ", " << y << ", " << z << ")";
        return ss.str();
    }
    
    void Vector3::registerPythonBindings() {
        boost::python::class_<Vector3>("Vector3",boost::python::init<>())
            .def(boost::python::init<Real,Real,Real>())
            
            .def_readwrite("x",&Vector3::x)
            .def_readwrite("y",&Vector3::y)
            .def_readwrite("z",&Vector3::z)
            
            .def(boost::python::self + Vector3())
            .def(boost::python::self - Vector3())
            .def(boost::python::self * Vector3())
            .def(boost::python::self / Vector3())
            .def(boost::python::self += boost::python::other<Vector3>())
            .def(boost::python::self -= boost::python::other<Vector3>())
            .def(boost::python::self *= boost::python::other<Vector3>())
            .def(boost::python::self /= boost::python::other<Vector3>())

            .def(boost::python::self * Real())
            .def(Real() * boost::python::self)
            .def(boost::python::self / Real())
            .def(boost::python::self += boost::python::other<Real>())
            .def(boost::python::self -= boost::python::other<Real>())
            .def(boost::python::self *= boost::python::other<Real>())
            .def(boost::python::self /= boost::python::other<Real>())
            
            .def(boost::python::self < boost::python::self)
            .def(boost::python::self > boost::python::self)
            
            .def(-boost::python::self)
            
            .def("length",&Vector3::length)
            .def("squaredLength",&Vector3::squaredLength)
            .def("dotProduct",&Vector3::dotProduct)
            .def("normalise",&Vector3::normalise)
            .def("crossProduct",&Vector3::crossProduct)
            .def("midPoint",&Vector3::midPoint)
            .def("makeFloor",&Vector3::makeFloor)
            .def("makeCeil",&Vector3::makeCeil)
            .def("perpendicular",&Vector3::perpendicular)
            .def("randomDeviant",&Vector3::pyRandomDeviant)
            .def("isZeroLength",&Vector3::isZeroLength)
            .def("normalisedCopy",&Vector3::normalisedCopy)
            .def("reflect",&Vector3::reflect)
            .def("positionEquals",&Vector3::pyPositionEquals)
            .def("directionEquals",&Vector3::directionEquals)
            .def("getRotationTo",&Vector3::pyGetRotationTo)
            
            .def("__repr__",&Vector3::toString)
        
            .def_readonly("UNIT_X",Vector3::UNIT_X)
            .def_readonly("UNIT_Y",Vector3::UNIT_Y)
            .def_readonly("UNIT_Z",Vector3::UNIT_Z)
            .def_readonly("ZERO",Vector3::ZERO)
        ;
    }
}
